import service from '@/api/index'
import { success, notice } from '@/utils/res'

const state = {}

const actions = {
  async recharge ({ commit }, data) {
    let res = await service.recharge(data)
    if (res.RET === 1) success(res.MSG)
    else notice(res.MSG)
    return res
  },
  async withdraw ({ commit }, data) {
    let res = await service.withdraw(data)
    if (res.RET === 1) success(res.MSG)
    else notice(res.MSG)
    return res
  },
  // 充值记录
  async rechargeList ({ commit }, data) {
    let res = await service.rechargeList(data)
    if (res.RET === 1) console.log('')
    else notice(res.MSG)
    return res
  },
  // 提现记录
  async withdrawList ({ commit }, data) {
    let res = await service.withdrawList(data)
    if (res.RET === 1) console.log('')
    else notice(res.MSG)
    return res
  },
  // 充值地址列表
  async collectionAccount ({ commit }, data) {
    let res = await service.collectionAccount(data)
    if (res.RET !== 1000) notice(res.MSG)
    return res
  },
  async withdrawEmail ({ commit }, data) {
    let res = await service.withdrawEmail(data)
    if (res.RET === 1) success(res.MSG)
    else notice(res.MSG)
    return res
  },
  async passwordEmail ({ commit }, data) {
    let res = await service.passwordEmail(data)
    if (res.RET === 1) success(res.MSG)
    else notice(res.MSG)
    return res
  },
  async passwordReset ({ commit }, data) {
    let res = await service.passwordReset(data)
    if (res.RET === 1) success(res.MSG)
    else notice(res.MSG)
    return res
  },
  async buy ({ commit }, data) {
    let res = await service.buy(data)
    if (res.RET === 1) success(res.MSG)
    else notice(res.MSG)
    return res
  },
  async invites ({ commit }, data) {
    let res = await service.invites(data)
    if (res.RET === 1) console.log(res.MSG)
    else notice(res.MSG)
    return res
  }
}

const mutations = {}

export default {
  namespaced: true,
  state,
  actions,
  mutations
}
